import java.util.Scanner;
public class Test {
        public String name = "abcdef";
        public String password = "123456";
        public void  login(String name,String password) {
            if (!this.name.equals(name)) {
                throw new UserNameException("你的用户名错误");
            }
            if (!this.password.equals(password)) {
                throw new PasswordException("你的密码错了");
            }
        }
        public static void main(String[] args) {
            Test test = new Test();
            System.out.println("请输入用户名和密码");
            Scanner scanner = new Scanner(System.in);
            String name = scanner.nextLine();
            String password = scanner.nextLine();
            try{
                test.login(name,password);
            }catch(UserNameException e){
                e.printStackTrace();
            }catch(PasswordException e){
                e.printStackTrace();
            }
        }
}
